package com.dcbeida.model;

import com.dcbeida.MyApplication;
import com.dcbeida.utils.GenApiHashUrl;
import com.dcbeida.utils.JsonGet;

import dc.medicine.com.okhttplib.OkHttpUtils;
import dc.medicine.com.okhttplib.callback.AbsCallback;

/**
 * Created by fancl
 */
public class SotresalesModel {

    private static SotresalesModel mInventoryModel;

    private SotresalesModel() {

    }

    public static SotresalesModel newInstance() {
        if (mInventoryModel == null) {
            return new SotresalesModel();
        } else {
            return mInventoryModel;
        }
    }

    /**
     * 13.	药店销售-查询患者信息列表（条件有手机号、身份证号、姓名）
     *
     * @param type         搜索条件：1=手机号，2=身份证号，3=姓名
     * @param keyword      搜索内容关键词
     * @param mAbsCallback
     */
    public void querypatient(int type, String keyword, AbsCallback mAbsCallback) {
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "querypatient")
                .paramsApp("params", new JsonGet().putopt("type", type).putopt("keyword", keyword)
                        .putopt("uid", MyApplication.user.getUid())
                        .tostring()).execute(mAbsCallback);
    }

    /**
     * 9.	药品监管码销售情况查询
     *
     * @param drugcode     药品监管码
     * @param mAbsCallback
     */
    public void querydrugorderinfo(String drugcode, AbsCallback mAbsCallback) {
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "querydrugorderinfo")
                .paramsApp("params", new JsonGet().putopt("drugcode", drugcode).tostring()).execute(mAbsCallback);
    }


    /**
     * 14.	药店销售-新增销售记录
     *
     * @param drugcodes        药品监管码codes（多个逗号“,”相隔）
     * @param patienttruename  患者姓名
     * @param patientidcardnum 患者身份证号
     * @param patientphonenum  患者手机号
     * @param quantity         购买数量
     * @param amount           金额
     * @param invoiceimgurl    发票图片url
     * @param doctorname       就诊医生
     * @param hospitalid       医院名称
     * @param mAbsCallback
     */
    public void adddrugsales(String drugcodes, String patienttruename, String patientidcardnum,
                             String patientphonenum, int quantity, String amount, String invoiceimgurl, String recipepicsurl,String doctorname, int hospitalid,
                             int cardtype,
                             AbsCallback mAbsCallback) {
        OkHttpUtils.getInstance().post(GenApiHashUrl.apiUrl).tag(this)
                .paramsApp("service", "adddrugsales")
                .paramsApp("params", new JsonGet().putopt("uid", MyApplication.user.getUid())
                        .putopt("drugcodes", drugcodes)
                        .putopt("patienttruename", patienttruename)
                        .putopt("patientidcardnum", patientidcardnum)
                        .putopt("patientphonenum", patientphonenum)
                        .putopt("quantity", quantity)
                        .putopt("amount", amount)
                        .putopt("invoiceimgurl", invoiceimgurl)
                        .putopt("recipepicsurl", recipepicsurl)
                        .putopt("doctorname", doctorname)
                        .putopt("hospitalid", hospitalid)
                        .putopt("cardtype", cardtype)
                        .tostring()).execute(mAbsCallback);
    }


    public void getCancel() {
        OkHttpUtils.getInstance().cancelTag(this);
    }
}
